function HandleTablePurchases(gui, item, options) {
  this._gui = gui;
  this._item = item;
  this._options = options;

  this._isPackage = (options && options.isPackage) ? options.isPackage : false;

  this._createElements();
}

HandleTablePurchases.prototype._createElements = function() {
  var tr, td, _self = this;
  
  if (this._item.length == 0) {
    tr = this._gui.purchasesTable.insertRow(-1);
    td = tr.insertCell(-1);
    td.colSpan = 6;
    td.style.borderRight = 'solid 1px #694247';
    td.style.borderBottom = 'solid 1px #694247';
    td.style.borderLeft = 'solid 1px #694247';
    td.style.height = '40px';
    td.style.backgroundColor = '#fff';;
    td.style.textAlign = 'center';
    td.appendChild(document.createTextNode('N/A'));
  }

  if (this._isPackage) {
    //for (var i = 0, il = this._item.length; i < il; i++) {
      //var object = this._item[i];
      //if (object && !object.sample) {
        //MiscUtils.remove(this._item, object, 'trackId');
      //}
    //}
    MiscUtils.sort(this._item, ['sample', 'name']);
    for (var j = 0, jl = this._item.length; j < jl; j++) {
      var packageItem = this._item[j];
      tr = this._gui.purchasesTable.insertRow(-1);
      new TableRowPurchase(tr, packageItem, this._options);
    }
  } else {
    MiscUtils.sort(this._item, ['name']);
    for (var i = 0, il = this._item.length; i < il; i++) {
      var purchase = this._item[i];
      tr = this._gui.purchasesTable.insertRow(-1);
      new TableRowPurchase(tr, purchase, this._options);
    }
  }
};